package com.xiyi.shouxin;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;
import org.springframework.web.client.RestTemplate;

@SpringBootApplication
@EnableJdbcRepositories("com.xiyi.shouxin.dao")
public class ShouxinApplication {
	/**
	 * 没有实例化RestTemplate时，初始化RestTemplate
	 */
	@ConditionalOnMissingBean(RestTemplate.class)
	@Bean
	public RestTemplate restTemplate() {
		RestTemplate restTemplate = new RestTemplate();
		return restTemplate;
	}

	/**
	 * 默认日志
	 */
	@ConditionalOnMissingBean(Logger.class)
	@Bean
	public Logger log() {
		return LoggerFactory.getLogger(getClass());
	}

	public static void main(String[] args) {
		SpringApplication.run(ShouxinApplication.class, args);
		System.out.println("启动成功");
		// Integer time = Integer.parseInt("01d8", 16);
		// System.out.println(time);
	}

}
